import { AccountGroup } from '../account'
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToOne } from 'typeorm'
import { ModuleRight } from './module-right.entity'
import { ModulePlugin } from './module-plugin.entity'

@Entity()
export class Module {
  @PrimaryGeneratedColumn()
  id: number

  @Column()
  title: string

  @OneToMany(type => ModuleRight, right => right.module)
  rights: ModuleRight[]

  @OneToMany(type => ModulePlugin, plugin => plugin.module)
  plugins: ModulePlugin[]

  @ManyToOne(type => AccountGroup, group => group.modules)
  group: AccountGroup
}
